package com.clearliang.myaidlclient;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by ClearLiang on 2019/1/9
 * boolean 类型  SDK>=29 才有
 * 所以一般用type进行 0 1判定
 */
public class Info implements Parcelable {
    private String content;
    private boolean isSave;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public boolean isSave() {
        return isSave;
    }

    public void setSave(boolean save) {
        isSave = save;
    }

    public Info() {
    }

    public Info(Parcel in) {
        content = in.readString();
        isSave = in.readByte() == 0;
    }

    public static final Creator<Info> CREATOR = new Creator<Info>() {
        @Override
        public Info createFromParcel(Parcel in) {
            return new Info(in);
        }

        @Override
        public Info[] newArray(int size) {
            return new Info[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(content);
        dest.writeByte((byte) (isSave?0:1));
    }

    /**
     * 参数是一个Parcel,用它来存储与传输数据
     */
    public void readFromParcel(Parcel dest) {
        //注意，此处的读值顺序应当是和writeToParcel()方法中一致的
        content = dest.readString();
        isSave = dest.readByte()==0;
    }

    //方便打印数据
    @Override
    public String toString() {
        return "content : " + content + ", isSave : " + isSave;
    }
}
